define("idcta-v2/analytics",["idcta-v2/config"],function(e){function t(e){o=e}function n(e,t,n){return function(){var r=s[e]&&s[e][t];a&&o&&!r&&document.dispatchEvent(new CustomEvent("bbc-user-event",{detail:{container:"id_cta_client_side",label:t,source:e}})),a=!1;var i=[].slice.apply(arguments),c=n.apply(this,i);return a=!0,c}}function r(t,r){e&&e.features.clientAnalytics&&Object.keys&&Object.keys(t).forEach(function(e){"function"==typeof t[e]&&(t[e]=n(r,e,t[e]))})}var i={},o=!0,a=!0,s={"idcta-1":{addUserOrigin:!0,getCookieInstance:!0,getIdFromCookie:!0,getUserDetailsFromCookie:!0,hasCookie:!0,initiateTokenRefresh:!0,Cta:!0,modifyPtrt:!0},"id-config":{getConfigAsync:!0},idCookie:{getInstance:!0},statusbar:{Statusbar:!0}};return i.setLoggingEnabled=t,i.withAnalytics=n,i.wrapModuleWithAnalytics=r,i}),define("idcta-v2/logger",["idcta-v2/analytics"],function(e){var t={};return t.logCaughtError=function(e){window.console&&e.message&&console.log(e)},t.logMessage=function(e){document.cookie.match(new RegExp("ckns_debugtoken=([^;]+)"))&&(window.tokenRefeshLog=window.tokenRefeshLog||[],window.tokenRefeshLog.push(e))},e.wrapModuleWithAnalytics(t,"logger"),t}),define("idcta-v2/optional",["idcta-v2/logger"],function(e){var t={};return t.load=function(t,n,r){n([t],r,function(t){var n=t.requireModules&&t.requireModules[0];e.logCaughtError("Could not load optional module: "+n),r(null)})},t}),define("idcta-v2/istats",["idcta-v2/analytics","idcta-v2/optional!istats-1"],function(e,t){if(t)return t;var n={getSite:function(){},_getLabels:function(){return{app_name:"",prod_name:""}}};return e.wrapModuleWithAnalytics(n,"istats-fallback"),n}),define("idcta-v2/apiUtils",["idcta-v2/es6-promise","idcta-v2/istats","idcta-v2/logger","idcta-v2/config"],function(e,t,n,r){function i(e,t){var n=e.split("#"),r=n[0],i=n[1],o=r.split("?"),a=o[1],s=a?a.split("&").reduce(function(e,t){var n=t.split("="),r=n[0],i=n[1];return e[r]=i,e},{}):{},c=Object.assign({},s,t),u=Object.keys(c).map(function(e){return e+"="+c[e]}).join("&"),g=u?o[0]+"?"+u:o[0];return i?g+"#"+i:g}function o(e,t){var n=t.substring(0,t.indexOf("=")+1);if(e.indexOf(n)>-1)return e;var r=e.split("#"),i=e.indexOf("?")>-1?"&":"?";return r.length>1?r[0]+i+t+"#"+r[1]:e+i+t}function a(){var e={context:"",userOrigin:""};try{var r=t.getSite();if(r){var i=r.split(" ").shift();return{context:i,userOrigin:i}}var o=t._getLabels();if(o){var a=o.app_name||o.prod_name,i=a?a.split(" ").shift():"";return{context:i,userOrigin:i}}return e}catch(t){return n.logCaughtError(t),e}}function s(){return a()}function c(){var e={context:"",userOrigin:""};return window.bbcpage&&window.bbcpage.getDestination?window.bbcpage.getDestination().then(function(t){if(t){return{context:t.replace(/_TEST$/i,"").replace(/_PS$/i,"").replace(/_GNL$/i,"").toLowerCase(),userOrigin:t}}return e}):u.Promise.resolve(e)}var u={};return u.verifyEndpointUrl=function(e,t){try{!1!==t&&(t=!0);if(/https?:\/\/(((www|ssl)(\.int|\.test|\.stage)?)|(pal\.sandbox\.dev))\.bbc\.(co\.uk|com)/.test(e))return/(\.com|\.co\.uk)\/.+/.test(e)&&(e=e.split(/(\.com|\.co\.uk)\/.+/)[0]+e.split(/(\.com|\.co\.uk)\/.+/)[1]),e;var r="";"https"==e.slice(0,5)?(r+=(t?"https://":"")+"ssl.",e.indexOf(".sandbox.")>-1&&(r+="sandbox.dev.")):(r+=t?"http://":"",e.indexOf(".sandbox.")>-1?r+="pal.sandbox.dev.":r+="www.");for(var i=["int","test","stage"],o=0;o-1&&(r+=i[o]+".");return/\.co\.uk/.test(e)?r+="bbc.co.uk":r+="bbc.com",r}catch(e){n.logCaughtError(e)}},u.alignTldWithHostname=function(e,t){try{var r=t||window.location.hostname,i=r.split(/(\.com|\.co\.uk)$/)[1],o=e.split(/(\.com|\.co\.uk)\/.+/)[1];return o!==i&&void 0!==i&&(e=e.replace(o,i)),e}catch(e){n.logCaughtError(e)}},u.appendProductToCtaElement=function(e){var t="",n="",r=e.getAttribute("href");if(r&&(-1===r.indexOf("userOrigin=")||-1===r.indexOf("context=")))return u.getProductNameAsync().then(function(r){if(void 0!==r&&""!==r){t="userOrigin="+r.userOrigin,n="context="+r.context;var i=e.getAttribute("href"),a=u.parseUrl(i);if(a){var s=(u.parseQueryString(a.search),a.pathname);-1===a.pathname.indexOf("/")&&(s="/"+a.pathname),e.setAttribute("href",a.protocol+"//"+a.host+s+o(o(a.search,t),n)+a.hash)}}})},u.appendQueryParameters=i,u.addQueryParameter=o,r.features.disableIStats||(u.getProductName=s),u.getProductNameAsync=c,u.Promise=function(){try{return"undefined"!=typeof Promise?Promise:e.Promise}catch(e){n.logCaughtError(e)}}(),u.loadUrlInHiddenIframe=function(e,t,r){try{return new u.Promise(function(i,o){n.logMessage('Creating iframe {src: "'+e+'", timeout: '+t+(r?', expectedPostMessages: ["'+r.join('", "')+'"]}':"}"));var a=document.createElement("iframe");a.scrolling="no",a.frameborder="0",a.width="0px",a.height="0px",a.border="0px",a.style.display="none",a.style.frameBorder="0px",a.style.borderStyle="none";var s=null,c=function(e){var t=e.message?"message":"data";return e.origin.match(/\.bbc\.(co\.uk|com)(:[0-9]+)*$/)&&-1!=r.indexOf(e[t])?(n.logMessage('Iframe received message "'+e[t]+'", resolving'),g(),i(e[t])):void n.logMessage('Iframe received unexpected message "'+e[t]+'", ignoring')},g=function(){s&&clearTimeout(s),r&&u.removeEventListener("message",c),document.body.removeChild(a)};r?u.addEventListener("message",c):a.onload=function(){return n.logMessage('Iframe with src "'+e+'" loading complete'),g(),i()},t&&(s=setTimeout(function(){return n.logMessage("Iframe with src "+e+" timed out after "+t+" milli seconds"),g(),o()},t)),a.src=e,document.body.appendChild(a)})}catch(e){n.logCaughtError(e)}},u.addEventListener=function(e,t,n){u.addEventListenerTo(window,e,t,n)},u.addEventListenerTo=function(e,t,r,i){try{return e.addEventListener?e.addEventListener(t,r,i):(t="message"==t?"onmessage":t,e.attachEvent(t,r))}catch(e){n.logCaughtError(e)}},u.removeEventListener=function(e,t){u.removeEventListenerFrom(window,e,t)},u.removeEventListenerFrom=function(e,t,r){try{return e.removeEventListener?e.removeEventListener(t,r):(t="message"==t?"onmessage":t,e.detachEvent(t,r))}catch(e){n.logCaughtError(e)}},u.getEnvFromUrl=function(){try{var e=window.location.href;return e.indexOf(".sandbox.")>-1?".sandbox.dev":e.indexOf(".int.")>-1?".int":e.indexOf(".test.")>-1?".test":e.indexOf(".stage.")>-1?".stage":""}catch(e){n.logCaughtError(e)}},u.parseUrl=function(e){try{var t=document.createElement("a");return t.href=e,t.query=t.search?u.parseQueryString(t.search):{},t}catch(e){n.logCaughtError(e)}},u.parseQueryString=function(e){try{"?"===e.charAt(0)&&(e=e.substring(1));for(var t={},r=e.split("&"),i=0;i(new Date).getTime()}catch(e){n.logCaughtError(e)}},u.timestampExpired=function(e){try{return e<(new Date).getTime()}catch(e){n.logCaughtError(e)}},u.generateFutureTimestamp=function(e){try{e=e||36e5;var t=new Date;return t.setTime(t.getTime()+e),t.getTime()}catch(e){n.logCaughtError(e)}},n.logCaughtError=function(e){window.console&&e.message&&console.log(e)},n.logMessage=function(e){document.cookie.match(new RegExp("ckns_debugtoken=([^;]+)"))&&(window.tokenRefeshLog=window.tokenRefeshLog||[],window.tokenRefeshLog.push(e))},u}),define("idcta-v2/id-config",["idcta-v2/config","idcta-v2/translations","idcta-v2/apiUtils","idcta-v2/logger","idcta-v2/analytics"],function(e,t,n,r,i){function o(e,t){if(t){var n=new Error("Deprecation warning: accessing the property '"+e+"' is deprecated and will be removed in a future version. Use '.getConfigAsync()' instead.");console.warn(n),r.logMessage(n.message)}}function a(r,i){var a={context:r.context,userOrigin:r.userOrigin};return{get announce_url(){return o("announce_url",i),n.alignTldWithHostname(e.announce_url)},get"bbcid-v5"(){return o("bbcid-v5",i),e["bbcid-v5"]},get child_parent_linking_url(){return o("child_parent_linking_url",i),e.child_parent_linking_url},get"id-availability"(){return o("id-availability",i),e["id-availability"]},get identity(){return o("identity",i),{cookieAgeDays:e.identity.cookieAgeDays,accessTokenCookieName:e.identity.accessTokenCookieName,idSignedInCookieName:e.identity.idSignedInCookieName}},get identityTokenExchangeUrl(){return o("identityTokenExchangeUrl",i),n.alignTldWithHostname(e.identityTokenExchangeUrl)},get privacy_settings_url(){return o("privacy_settings_url",i),e.privacy_settings_url},get ptrt(){return o("ptrt",i),window.location.href},get register_url(){return o("register_url",i),n.appendQueryParameters(n.alignTldWithHostname(e.register_url),a)},get settings_url(){return o("settings_url",i),n.appendQueryParameters(e.settings_url,a)},get signin_url(){return o("signin_url",i),n.appendQueryParameters(n.alignTldWithHostname(e.signin_url),a)},get signout_url(){return o("signout_url",i),n.appendQueryParameters(e.signout_url,a)},get status_url(){return o("status_url",i),n.appendQueryParameters(e.status_url,a)},get tld(){return o("tld",i),s},get tokenRefresh(){return o("tokenRefresh",i),e.tokenRefresh||!1},get tokenRefresh_signout_url(){return o("tokenRefresh_signout_url",i),n.alignTldWithHostname(e.tokenRefresh_signout_url)},get tokenRefresh_url(){return o("tokenRefresh_url",i),n.alignTldWithHostname(e.tokenRefresh_url)},get translation_signedin(){return o("translation_signedin",i),t.translation_statusbar_signedin},get translation_signedout(){return o("translation_signedout",i),t.translation_statusbar_signedout}}}var s=function(){var e=window.location.host.split(".");return"co"===e[e.length-2]&&"uk"===e[e.length-1]?e[e.length-3]+".co.uk":e[e.length-2]+"."+e[e.length-1]}(),c=e.features.disableIStats,u=c?{}:a(n.getProductName(),!0),g=n.getProductNameAsync().then(a);return u.getConfigAsync=function(){return g},u.getDomain=function(){return s},u.getIdentity=function(){return e.identity},u.getFeatureDecisions=function(){return e.features},u.getUsiDestinationWhitelist=function(){return e.usiDestinationWhitelist},u.getExperiments=function(){return e.experiments},c||(u.getConfig=function(){return o("getConfig",!0),u}),i.wrapModuleWithAnalytics(u,"id-config"),u}),define("idcta-v2/idCookie",["idcta-v2/id-config","idcta-v2/logger","idcta-v2/analytics"],function(e,t,n){function r(){try{return p?(p.refreshCookie(),p):(p=new s,n.wrapModuleWithAnalytics(p,"idCookieInstance"),p)}catch(e){t.logCaughtError(e)}}function i(e){try{p=e}catch(e){t.logCaughtError(e)}}function o(e){try{var t=window.atob(e),n=t.lastIndexOf("}"),r=t.substring(0,n+1);return JSON.parse(r)}catch(e){return null}}function a(e,n,r,i){try{n=n||"";var o="";if(r){var a=new Date;a.setTime(a.getTime()+r),o="Expires="+a.toUTCString()+"; "}n=i?window.btoa(n):n,document.cookie=e+"="+n+"; "+o+"Domain="+g+"; Path=/"}catch(e){t.logCaughtError(e)}}function s(){function e(){var e=new RegExp(d+"=([\\w]+)"),t=document.cookie.match(e);if(!t)return void s();var n=o(t[1]);if(!n||!r(n)||i(n))return void s();c.valid=!0,c.displayname=n.dn,c.timestamp=n["jwt-exp"]}function n(){var e=c.cookieAgeDays*u;return(new Date).getTime()-c.timestamp>=e}function r(e){return e.hasOwnProperty("ps")&&e.hasOwnProperty("jwt-exp")&&e.hasOwnProperty("tkn-exp")&&(e.hy||e.hasOwnProperty("ses-exp"))}function i(e){var t=(new Date).getTime();return(e["jwt-exp"]||0)<=t}function s(){c.valid=!1,c.id="",c.username="~",c.displayname="",c.timestamp=""}var c=this;this.valid=!1,this.id="",this.username="~",this.displayname="",this.timestamp="",this.cookieAgeDays=l,this.isIdv5On=!0,this.refreshCookie=function(){try{e()}catch(e){t.logCaughtError(e)}},this.hasCookie=function(){try{return n()&&s(),c.valid}catch(e){t.logCaughtError(e)}},this.hasAccessTokenExpired=function(){try{var e=this.getUserDetailsFromCookie();if(!e)return!0;var n=(new Date).getTime();return(e["tkn-exp"]||0)<=n}catch(e){t.logCaughtError(e)}},this.hasJwtTokenExpired=function(){try{var e=this.getUserDetailsFromCookie();if(!e)return!0;var n=(new Date).getTime();return(e["jwt-exp"]||0)<=n}catch(e){t.logCaughtError(e)}},this.isHybridApp=function(){try{var e=this.getUserDetailsFromCookie();return!!e&&(e.hy||!1)}catch(e){t.logCaughtError(e)}},this.getError=function(){try{var e=this.getUserDetailsFromCookie();return e?e.ec||null:null}catch(e){t.logCaughtError(e)}},this.getIdFromCookie=function(){try{var e=this.getUserDetailsFromCookie();return e?e.ps:null}catch(e){t.logCaughtError(e)}},this.getHidFromCookie=function(){return this.getCookie(h)||this.getCookie(m)},this.isPersonalisationEnabled=function(){try{var e=this.getUserDetailsFromCookie();return e&&e.ep}catch(e){return t.logCaughtError(e),!1}},this.getUserDetailsFromCookie=function(){try{if(!this.hasCookie())return null;var e=new RegExp(d+"=([\\w]+)"),n=document.cookie.match(e);if(!n)return null;var i=decodeURIComponent(n[1]).split("|"),a=o(i.toString());return a&&r(a)?a:null}catch(e){t.logCaughtError(e)}},this.getNameFromCookie=function(){try{return this.hasCookie()&&(c.displayname&&""!==c.displayname)?c.displayname.replace(/\+/g," "):null}catch(e){t.logCaughtError(e)}},this.getAccessToken=function(){try{if(!this.hasCookie())return null;var e=new RegExp(f+"=([^;]*)"),n=document.cookie.match(e);return null!==n?n[1]:null}catch(e){t.logCaughtError(e)}},this.getCookie=function(e,n){try{var r=new RegExp(e+"=([^\\s;]*)"),i=document.cookie.match(r);if(!i)return null;if(!0!==n)return i[1];return o(decodeURIComponent(i[1]))}catch(e){t.logCaughtError(e)}},this.setCknsIdCookieProperty=function(e,n){try{var r=this.getUserDetailsFromCookie();if(!r)return;n?r[e]=n:delete r[e];var i=r["jwt-exp"]?r["jwt-exp"]:u*l;a(d,JSON.stringify(r),i,!0)}catch(e){t.logCaughtError(e)}},this.unsetCookie=function(e){try{document.cookie=e+"=; Expires=Thu, 01 Jan 1970 00:00:00 GMT; Domain="+g+"; Path=/"}catch(e){t.logCaughtError(e)}},function(){e()}()}var c={},u=864e5;n.setLoggingEnabled(!1);var g=e.getDomain(),d=e.getIdentity()&&e.getIdentity().idSignedInCookieName?e.getIdentity().idSignedInCookieName:"ckns_id",l=e.getIdentity()&&e.getIdentity().cookieAgeDays?e.getIdentity().cookieAgeDays:730,f=e.getIdentity()&&e.getIdentity().accessTokenCookieName?e.getIdentity().accessTokenCookieName:"ckns_atkn",h="ckns_sylphid",m="ckpf_sylphid";n.setLoggingEnabled(!0);var p;return c.getInstance=r,c.setInstance=i,n.wrapModuleWithAnalytics(c,"idCookie"),c}),define("idcta-v2/tokenRefresh",["idcta-v2/id-config","idcta-v2/idCookie","idcta-v2/apiUtils","idcta-v2/logger","idcta-v2/analytics"],function(e,t,n,r,i){function o(i,o){var u=t.getInstance();try{if(!u.hasCookie()){var g="ckns_id cookie is missing, invalid or expired";return n.Promise.reject(new a(g))}if(u.isHybridApp()){var g="hybrid app detected";return n.Promise.reject(new a(g))}var d=u.getError();if(d&&n.timestampInFuture(d.retryAfter)){var g="retry period has not passed";return n.Promise.reject(new a(g,d.retryAfter))}if(!0!==i&&!u.hasAccessTokenExpired())return n.Promise.resolve();var l=function(e){var t={credentials:"include",headers:{"Content-Type":"application/json"}};return fetch(e,t)};return void 0===s[o]&&(s[o]=e.getConfigAsync().then(function(e){var t=e.tokenRefresh_url;return t=o?n.alignTldWithHostname(t,o):t,l(t)})),s[o].then(function(){s[o]=void 0}).catch(function(e){return s[o]=void 0,c(e)})}catch(e){r.logCaughtError(e)}}function a(e,t){this.name="TokenRefreshError",this.message=e,this.retryAfter=t}var s={},c=function(n){return e.getConfigAsync().then(function(e){var r=(new Date).getTime()+(e.tokenRefresh?15e3:36e5);throw n.retryAfter=r,t.getInstance().setCknsIdCookieProperty("ec",n),n})};a.prototype=Error.prototype;var u={};return u.refreshAccessToken=o,i.wrapModuleWithAnalytics(u,"tokenRefresh"),u}),define("idcta-v2/idcta-1",["idcta-v2/idCookie","idcta-v2/apiUtils","idcta-v2/tokenRefresh","idcta-v2/logger","idcta-v2/id-config","idcta-v2/es6-promise","idcta-v2/analytics"],function(e,t,n,r,i,o,a){function s(t,n){var r=["idcta-v2/signInPrompt","idcta-v2/mvt"];requirejs(r,function(r,o){var a=e.getInstance().hasCookie(),s=r.hasInitialised(),c=i.getExperiments();if(a&&!s||(o.bucketUser(c.usiApiName),o.sendEvent("page_view")),a&&s)o.sendEvent("page_view_signed_in");else if(!a){var u=o.getVariantName(c.usi);o.sendEvent("page_view_signed_out"),r.initialise(t,n,u)}})}function c(t){try{this.id=t.id,this.element=document.getElementById(t.id),this.states=t.states;var n=this;p.ctas[n.id]=n,!0===t.publiclyCacheable&&(e.getInstance().hasCookie()?g(n):n.element.getElementsByTagName("span")[0].innerText=n.states.unauthorised.signedout)}catch(e){r.logCaughtError(e)}}function u(e){var n=document.querySelectorAll("#"+e),r=function(){t.appendProductToCtaElement(this)};if(n.length)for(var i=0;i-1&&(o.className=o.className.replace(/small|medium|large/g,n)),s.indexOf(i)>-1&&(o.className=o.className.replace(/blue|white/g,i));var c=document.querySelectorAll("#"+e+" span a");for(var u in c)c.hasOwnProperty(u)&&t.appendProductToCtaElement(c[u])}catch(e){r.logCaughtError(e)}}function h(e,n){try{var i=document.querySelectorAll("#"+e+" a");if(!i.length)throw"No cta elements found with provided Id";for(var o in i)if(i.hasOwnProperty(o)){var a=i[o].getAttribute("href"),s=decodeURIComponent(a).match(/ptrt\=([a-zA-Z:\/\/\_\\0-9.-]*)&?/).pop();s=encodeURIComponent(s);var c=a.substring(0,a.indexOf(s)),u=a.substring(a.indexOf(s)+s.length);i[o].setAttribute("href",c+n+u),t.appendProductToCtaElement(i[o])}}catch(e){r.logCaughtError(e)}}function m(){try{var t={},n=e.getInstance();if(!n.hasCookie())return t;if(t.bbc_identity="1",!n.isPersonalisationEnabled())return t;var i=n.getHidFromCookie();return i&&(t.bbc_hid=i),t}catch(e){return r.logCaughtError(e),{}}}var p={signals:{},ctas:{}};a.setLoggingEnabled(!1);var v=i.getFeatureDecisions();if(a.setLoggingEnabled(!0),window.bbcpage&&window.bbcpage.getDestination&&window.bbcpage.getContentType&&window.bbcpage.getAdditionalProperties&&v.showUsiModal){var y=["index-correspondent","index-home","index-section"],k=["article","article-correspondent","article-media-asset","article-photo-gallery","oppm","sports-data"];o.all([window.bbcpage.getDestination(),window.bbcpage.getContentType(),window.bbcpage.getAdditionalProperties()]).then(function(e){var t=e[0]&&e[0].toLowerCase(),n=e[1],r=e[2]&&e[2].app_type;if(-1!==i.getUsiDestinationWhitelist().indexOf(t)&&"mobile-app"!==r){if(y.indexOf(n)>=0)return s(t,"index");if(k.indexOf(n)>=0)return s(t,"article")}}).catch(function(e){console.error("Caught USI initialisation error in IDCTA idcta-1 module",e)})}return p.Cta=c,p.modifyCta=f,p.modifyPtrt=h,p.addUserOrigin=u,p.initiateTokenRefresh=d,p.initiateUserUplift=l,v.disableIStats||(p.getIStatsLabels=m),p.hasCookie=function(){return e.getInstance().hasCookie()},p.getCookieInstance=function(){return e.getInstance()},p.getIdFromCookie=function(){return e.getInstance().getIdFromCookie()},p.getUserDetailsFromCookie=function(){return e.getInstance().getUserDetailsFromCookie()},p.getNameFromCookie=function(){return e.getInstance().getNameFromCookie()},p.getAccessToken=function(t){return e.getInstance().getAccessToken(t)},a.wrapModuleWithAnalytics(p,"idcta-1"),p}); //# sourceMappingURL=idcta-1.js.map